/*
The mbr.h header file defines structures and prototypes for the Master Boot Record of Hard Disks
*/

#ifndef _VFS_MBR_H
#define _VFS_MBR_H

/* from lib files */
#include <types.h>

/* These two are relative to the "state" field  */
#define PARTITION_STATE_INACTIVE     0x00
#define PARTITION_STATE_ACTIVE       0x80

struct partition_type {
  byte_t id;
  char *description;
};

#pragma pack(1)

struct partition_entry {
  byte_t state;
  byte_t start_h;
  word_t start_cs;
  byte_t type;
  byte_t end_h;
  word_t end_cs;
  dword_t offset;    /* no. of sectors between MBR and first partition sector */
  dword_t size;      /* no. of sectors in partition */
};

struct MBR {
  byte_t boot_code[446];
  struct partition_entry partition_0;
  struct partition_entry partition_1;
  struct partition_entry partition_2;
  struct partition_entry partition_3;
  byte_t boot_signature[2];                /* 0x55, 0xAA */
};

#pragma pack(4)

// Reference to partition types array
extern struct partition_type partition_types[];

/* Functions prototypes */
extern int vfs_mbr_initialize(int controller,int disk_number,ptr_list_t part_list);
extern int vfs_mbr_diagnostics(void);

#endif /* _VFS_MBR_H */
